const express = require('express')
const app = express()
const port = 5001

app.use(
    (request, response, next) => {
        console.log("有人请求服务器1了");
        console.log("请求的资源是：", request.url);
        console.log("请求来自于：", request.get('Host'));
        next()
    }
)



app.get('/cars', (req, res) => {
    const cars = [
        { id: '001', name: '小米' },
        { id: '002', name: '红旗' },
        { id: '003', name: '长城' },
    ]
    res.send(cars)
})
app.listen(
    port,
    (err) => {
        if (!err) {
            console.log(`服务器1启动成功了，请求学生信息地址为：http://localhost:${port}/cars`)
        }
    }
)